package com.lzy.mall.product.web;

import com.lzy.mall.product.entity.PmsCategory;
import com.lzy.mall.product.service.PmsCategoryService;
import com.lzy.mall.product.vo.Catelog2Vo;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author lzy
 * @date 2021/9/8 11:15
 */
@Controller
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class IndexWeb {

    private final PmsCategoryService categoryService;

    @GetMapping({"/","/index","/index.html"})
    public String indexPage(Model model){
        List<PmsCategory> list = categoryService.getLevel1();
        model.addAttribute("categorys",list);
        return "index";
    }

    @ResponseBody
    @RequestMapping("/index/catalog.json")
    public String getCatelogJson() {
        String map = categoryService.getCatelogJson();
        return map;
    }
}
